from Employee import Employee

list_employees = [
    Employee(1001,9001,"唐僧",60000),
    Employee(1002,9002,"孙悟空",50000),
    Employee(1003,9002,"猪八戒",40000),
    Employee(1004,9001,"沙僧",30000),
    Employee(1005,9001,"小白龙",1500),
]


# Lambda表达式来实现
def find_all(condition):
    for item in list_employees:
        if condition(item):
            yield item


# 在员工列表中查找所有部门是9001的员工
for item in find_all(lambda item: item.did == 9001):
    print(item)

# 在员工列表中查找所有姓名是2个字的员工
print("===============")
for item in find_all(lambda item: len(item.name) == 2):
    print(item)
